<?php
/**
 * Created by PhpStorm.
 * User: 农夫
 * Date: 2017/9/11
 * Time: 10:19
 */
namespace app\model;

use think\Model;
use My\CategoryTree;
use think\Db;

class AdminGroup extends Model
{
    static $tablue_nmae = 'admin_group';

    /**
     * 查询一条数据
     * @param array $where
     * @param array $field
     * @return array|false|\PDOStatement|string|Model
     */
    static public function findService($where = array(), $field = array())
    {
        $return = Db::name(self::$tablue_nmae)->where($where)->field($field)->find();
        return $return;
    }

    /**
     * 删除数据
     * @param array $where
     * @return int
     */
    static public function deleteService($where = array())
    {
        $return = Db::name(self::$tablue_nmae)->where($where)->delete();
        return $return;
    }

    /**
     * 添加数据
     * @param array $data
     * @return $this
     */
    static public function addService($data = array())
    {
        $return = Db::name(self::$tablue_nmae)->insertGetId($data);
        return $return;
    }

    /**
     * 更新数据
     * @param array $where
     * @param array $data
     * @return $this
     */
    static public function updateServer($where = array(), $data = array())
    {
        $return = Db::name(self::$tablue_nmae)->where($where)->update($data);
        return $return;
    }

    /**
     * 获取列表数据
     * @param array $where
     * @param array $field
     * @return false|\PDOStatement|string|\think\Collection
     */
    static public function listService($where = array(), $field = array())
    {
        $return = Db::name(self::$tablue_nmae)->where($where)->field($field)->select();
        return $return;
    }

    /**
     * 数据分页
     * @param array $where
     * @param array $field
     * @return \think\Paginator
     */
    static public function pageService($where = array(), $field = array())
    {
        $return = Db::name(self::$tablue_nmae)->where($where)->field($field)->paginate(pagesize, false, ['query' => request()->param()]);
        return $return;
    }

}